﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using RookieGrow.Domain.Model.SportsStore;
using RookieGrow.Data.SportsStore;

namespace RookieGrow.Domain.SportsStore
{
    public class LimitShoppingCart : ShoppingCart
    {
        public decimal ItemLimit { get; set; }

        public LimitShoppingCart(IValueCalculator calculator, IDataProvider<Product> productDataProvider)
            : base(calculator, productDataProvider)
        {
            // nothing to do here
        }

        public override decimal CalculateStockValue()
        {
            // define the set of products to sum
            List<Product> products = productDataProvider.GetList();

            // filter out any items that are over the limit
            List<Product> filteredProducts = products
                .Where(e => e.Price < ItemLimit).ToList();

            // perform the calculation
            return calculator.ValueProducts(filteredProducts);
        }
    }
}
